/**
 * Created by VIETBINH on 20/08/14.
 */
UnSign = function(str) {
    str = str.toLowerCase();
    str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, "a");
    str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, "e");
    str = str.replace(/ì|í|ị|ỉ|ĩ/g, "i");
    str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, "o");
    str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, "u");
    str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, "y");
    str = str.replace(/đ/g, "d");
    str = str.replace(/!|@|%|\^|\*|\(|\)|\+|\=|\<|\>|\?|\/|,|\.|\:|\;|\'| |\"|\&|\#|\[|\]|~|$|_/g, "-");
    /* tìm và thay thế các kí tự đặc biệt trong chuỗi sang kí tự - */
    str = str.replace(/-+-/g, "-"); //thay thế 2- thành 1-
    str = str.replace(/^\-+|\-+$/g, "");
    //cắt bỏ ký tự - ở đầu và cuối chuỗi
    return str;
};


function openKCFinder(field) {
    window.KCFinder = {
        callBack: function(url) {
            field.value = url;
            window.KCFinder = null;
        }
    };
    window.open(base_url+'/editor2/kcfinder/browse.php?type=files&dir=files/public', 'kcfinder_textbox',
        'status=0, toolbar=0, location=0, menubar=0, directories=0, ' +
            'resizable=1, scrollbars=0, width=800, height=600'
    );
}
function getEditor(id,type,width,height)
{
    if(type == 'tiny'){
        CKEDITOR.replace( id.substr(1), {
            width: width,
            height: height,
            toolbar : 'Basic',
            language: 'vi',
            entities_latin: false
//                        [
//                            { name: 'basicstyles', items : [ 'Bold','Italic' ] },
//                            { name: 'paragraph', items : [ 'NumberedList','BulletedList' ] },
//                            { name: 'tools', items : [ 'Maximize','-','About' ] }
//                        ]
        });
    }else{
        CKEDITOR.replace(id.substr(1), {
            width: width,
            height: height,
            toolbar: 'Full',
            language: 'vi',
            entities_latin: false,
            filebrowserBrowseUrl: base_url+'/editor2/kcfinder/browse.php?type=files',
            filebrowserImageBrowseUrl: base_url+'/editor2/kcfinder/browse.php?type=images',
            filebrowserFlashBrowseUrl: base_url+'/editor2/kcfinder/browse.php?type=flash',
            filebrowserUploadUrl: base_url+'/editor2/kcfinder/upload.php?type=files',
            filebrowserImageUploadUrl: base_url+'/editor2/kcfinder/upload.php?type=images',
            filebrowserFlashUploadUrl: base_url+'/editor2/kcfinder/upload.php?type=flash'
        });
    }
}


function generate(type,text) {
//        $.noty.defaults = {
//            layout: 'top',
//            theme: 'defaultTheme',
//            type: 'alert',
//            text: '', // can be html or string
//            dismissQueue: true, // If you want to use queue feature set this true
//            template: '<div class="noty_message"><span class="noty_text"></span><div class="noty_close"></div></div>',
//            animation: {
//                open: {height: 'toggle'},
//                close: {height: 'toggle'},
//                easing: 'swing',
//                speed: 500 // opening & closing animation speed
//            },
//            timeout: false, // delay for closing event. Set false for sticky notifications
//            force: false, // adds notification to the beginning of queue when set to true
//            modal: false,
//            maxVisible: 5, // you can set max visible notification for dismissQueue true option,
//            killer: false, // for close all notifications before show
//            closeWith: ['click'], // ['click', 'button', 'hover']
//            callback: {
//                onShow: function() {},
//                afterShow: function() {},
//                onClose: function() {},
//                afterClose: function() {}
//            },
//            buttons: false // an array of buttons
//        };
    var n = noty({text: 'noty - a jquery notification library!'});
    var n = noty({
        text        : text,
        type        : type,
        dismissQueue: true,
        timeout     : 5000, // delay for closing event. Set false for sticky notifications
        layout      : 'topRight',
        theme       : 'defaultTheme',
        maxVisible  : 10
    });
    console.log('html: ' + n.options.id);


}
//   generate('alert','abc');
//    generate('information');
//    generate('error');
//    generate('warning');
//    generate('notification');
//    generate('success');

function MyNotify(type,text)
{
    $(".notify").addClass(type);
    $(".notify").text(text);
    $(".notify").show('slow').fadeOut(5000);
}

